unit FormNewVoxel;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls;

type
  TFrmNewVoxel = class(TForm)
    grpSize: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    txtX: TEdit;
    txtY: TEdit;
    txtZ: TEdit;
    btnOK: TButton;
    grpType: TGroupBox;
    radTibSun: TRadioButton;
    radRedAlert2: TRadioButton;
    btnCancel: TButton;
    procedure btnOKClick(Sender: TObject);
    procedure btnCancelClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    InputX, InputY, InputZ: integer;
  end;

implementation

uses FormMain;

{$R *.DFM}

procedure TFrmNewVoxel.btnOKClick(Sender: TObject);
  procedure ValError(Edit: TEdit);
  begin
    MessageDlg('Please input an integer between 1 and 255', mtError, [mbOK], 0);
    Edit.SetFocus;
  end;
var
  code: Integer;
begin
  Val(txtX.Text, InputX, code);
  if (code <> 0) or not (InputX in [1..255]) then begin ValError(txtX); Exit; end;
  Val(txtY.Text, InputY, code);
  if (code <> 0) or not (InputY in [1..255]) then begin ValError(txtY); Exit; end;
  Val(txtZ.Text, InputZ, code);
  if (code <> 0) or not (InputZ in [1..255]) then begin ValError(txtZ); Exit; end;
  ModalResult := mrOK;
end;

procedure TFrmNewVoxel.btnCancelClick(Sender: TObject);
begin
  ModalResult := mrCancel;
end;

end.
